home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / howtos1r / module1.bas < prev    next >
BASIC Source File  |  1999-08-11  |  3KB  |  96 lines

  1. Attribute VB_Name = "Module1"
  2. Global MemLoad(32767) As Integer
  3. Global Phys(32767) As Integer
  4. Global Virt(32767) As Integer
  5. Global OldPos As Integer
  6. Global Currpos As Integer
  7. Global MemPC As Integer
  8. Global PhysPC As Integer
  9. Global VirtPC As Integer
  10.  
  11. Global FileToBeLoaded As String
  12.  
  13.  
  14. Sub LOAD(Filename As String)
  15. '****LOADING****
  16. 'Loading the whole file as a string and then dividing it out again
  17. 'goes a lot quiker than load everything in using "Line Input" method
  18. ' especially when you have the potential of 98301 figures
  19.  
  20.  
  21. Dim IntD1 As Integer, IntD2 As Integer
  22.         Open Filename For Input As #2
  23.             Input #2, FileToBeLoaded    'Gets Whole File as 1 String
  24.         Close #2
  25. ProcessIT
  26. End Sub
  27.  
  28. Sub ProcessIT()
  29. Dim BugLine As String
  30.  
  31. IntD1 = InStr(1, FileToBeLoaded, Chr$(13))
  32. IntD2 = InStr(IntD1 + 1, FileToBeLoaded, Chr$(13))
  33. BugLine = Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1)    'The First Line is always Cocked Up
  34.  
  35. IntD1 = IntD2 + 1
  36. IntD2 = InStr(IntD1, FileToBeLoaded, Chr$(13))
  37. Currpos = Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1)  'Note: the string we want goes here
  38.  
  39. 'Load DATA in to the arrays
  40. For i = 0 To Currpos
  41.         IntD1 = IntD2 + 1
  42.         IntD2 = InStr(IntD1, FileToBeLoaded, Chr$(13))
  43.         MemLoad(i) = Val(Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1))
  44.         
  45.         IntD1 = IntD2 + 1
  46.         IntD2 = InStr(IntD1, FileToBeLoaded, Chr$(13))
  47.        Phys(i) = Val(Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1))
  48.         
  49.         IntD1 = IntD2 + 1
  50.         IntD2 = InStr(IntD1, FileToBeLoaded, Chr$(13))
  51.         Virt(i) = Val(Mid$(FileToBeLoaded, IntD1, IntD2 - IntD1))
  52. Next i
  53.  
  54. 'MOVE PICGRAPH INTO PLACE
  55.  
  56. frmGraph.picGraph.Width = Currpos
  57. frmGraph.picGraph.Left = frmGraph.Picture1.ScaleWidth - frmGraph.picGraph.Width
  58.  
  59. 'DRAW IN OLD LINES
  60.  
  61. For i = 1 To Currpos
  62. frmGraph.picGraph.Line (i - 1, 100 - MemLoad(i - 1))-(i, 100 - MemLoad(i)), RGB(255, 0, 0)
  63. frmGraph.picGraph.Line (i - 1, 100 - Phys(i - 1))-(i, 100 - Phys(i)), RGB(0, 255, 0)
  64. frmGraph.picGraph.Line (i - 1, 100 - Virt(i - 1))-(i, 100 - Virt(i)), RGB(0, 255, 255)
  65. Next i
  66. frmGraph.picGraph.Line (Currpos, 0)-(Currpos, 100), RGB(255, 255, 255)  'Draws a Grey Line where the new file has strarted
  67. End Sub
  68.  
  69.  
  70. Sub SAVE(Filename As String)
  71. On Error GoTo Twat:
  72. Dim filestring As String
  73. 'COMPOSE STRING TO SAVE
  74. filestring = "Graph From " & Format$(Date) & " at " & Format$(Time) + Chr$(13)
  75. filestring = filestring & " " & Chr$(13)    'When using the kind of load process seen in "sub_Load"
  76. 'this string is a kind of dummy line, it never returns as what you think
  77. filestring = filestring & Currpos & Chr$(13)    'Denotes how many entries there will be into the File
  78. For i = 0 To Currpos
  79.     filestring = filestring & MemLoad(i) & Chr$(13)
  80.     filestring = filestring & Phys(i) & Chr$(13)
  81.     filestring = filestring & Virt(i) & Chr$(13)
  82. Next i
  83. filestring = filestring & "Clone Software 1999 - Jack Hoxley" & Chr$(13)
  84.  
  85. Open Filename For Output As #6
  86. Write #6, filestring
  87. Close #6
  88.         frmGraph.lblopt(1).ForeColor = RGB(0, 255, 0)
  89. MsgBox "Saved to '" & Filename & "' Succesfully", vbInformation, "Save"
  90. Exit Sub
  91. Twat:
  92. MsgBox "Could not Save to '" & Filename & "'", vbInformation, "Save"
  93. End Sub
  94.  
  95.  
  96.